package com.myteam.fugaocrm.sqldb.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.myteam.fugaocrm.modle.FgPartnerContact;
import com.myteam.fugaocrm.modle.FgPartnerProduct;

/**
 * 供应商联系人Mapper
 * @author BZX
 */
public interface FgPartnerContactMapper {
	/** 查询全部供应商公司 */
	@Select(
		  "SELECT contact.*,company.partner_company_name "
		+ "FROM fg_partner_contact contact "
		+ "LEFT JOIN fg_partner_company company ON company.partner_company_id = contact.partner_company_id "
		+ "WHERE contact.is_delete = 0"
	)
	public List<FgPartnerContact> all();
	
	/** 删除一个供应商公司 */
	@Select("update fg_partner_contact set is_delete = 1 where contact_id = #{contactId}")
	public void deleteOne(@Param("contactId") Integer contactId);
	
	/** 新增一个供应商公司 */
	@Select("insert into fg_partner_contact(partner_company_id,contact_name,contact_mobile,contact_email,created_date,created_user) values(#{partnerCompanyId},#{contactName},#{contactMobile},#{contactEmail},#{createdDate},#{createdUser})")
	public void insert(Map<String, Object> params);
	
	/** 修改一个供应商公司 */
	@Select("update fg_partner_contact set partner_company_id=#{partnerCompanyId},contact_name=#{contactName},contact_mobile=#{contactMobile},contact_email=#{contactEmail},modified_user=#{modifiedUser},modified_date=#{modifiedDate} where contact_id = #{contactId}")
	public void update(Map<String, Object> params);
	
	/** 根据供应商公司ID查询该公司全部联系人 */
	@Select("SELECT * FROM fg_partner_contact WHERE is_delete = 0 AND partner_company_id = #{partnerCompanyId}")
	public List<FgPartnerContact> selectList(Integer partnerProductId);
}
